﻿define('data/projects', ['data', 'loc', 'root'], function (data, loc, root) {
    
    var ListProject = function (fromServer) {
        $.extend(this, fromServer);
        this.isDeleting = ko.observable(false);
        var addDate = moment(this.CreateDate);
        this.CreateDate = addDate.format('MMMM Do YYYY');
    };

    var Project = function (fromServer) {
        fromServer = fromServer || {};
        $.extend(this, fromServer);
        this.Id = fromServer.Id || 0;
        var deadline = moment(fromServer.Deadline);
        this.Deadline = ko.observable(deadline ? deadline.format('MM/DD/YYYY') : '');
        this.Name = ko.observable(fromServer.Name).extend({ required: true });
        this.Description = ko.observable(fromServer.Description);
        this.CustomerId = ko.observable(fromServer.CustomerId).extend({ required: true });
        this.CustomerName = ko.observable(fromServer.CustomerName);
    };

    return $.extend(new data.Crud('projects'), {
        Project: Project,
        ListProject: ListProject,
        LookupLink: root + 'projects/lookup'
    });
});